/**
  角色接口模块
 */

import http from '@/utils/request'

/**
 * 获取所有角色列表
 * @param {*} page 当前页码(默认第一页)
 * @param {*} pagesize 每页显示条数(默认每页5条)
 */
export const reqGetRoleList = (page = 1, pagesize = 5) => {
  return http({
    method: 'get',
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}

/**
 * 根据id删除角色
 * @param {*} id 传递的角色id
 */
export const reqDelRoleById = (id) => {
  return http({
    method: 'delete',
    url: `/sys/role/${id}`
  })
}

/**
 * 新增一条角色
 * @param {*} form {name, description}
 * @returns
 */
export const reqAddRole = (form) => {
  return http({
    method: 'post',
    url: '/sys/role',
    data: form
  })
}

/**
 * 根据id获取角色详情
 * @param {*} id
 */
export const reqGetRoleDetail = (id) => {
  return http({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

/**
 * 根据id更新角色
 * @param {*} form form中一定要有id
 * @returns
 */
export const reqUpdateRole = (form) => {
  return http({
    method: 'put',
    url: `/sys/role/${form.id}`,
    data: form
  })
}
